package com.nicolasprof.profgallery.navigation {
	import gs.TweenLite;

	import com.nicolasprof.profgallery.Engine;

	import flash.display.Sprite;
	import flash.events.Event;

	/**
	 * @author Nicolas Prof
	 */
	public class BlockLayer extends Sprite {
		
		public function BlockLayer() {
		}
		public function draw() : void {
			var config: XML = Engine.CONFIG_XML;
			this.graphics.beginFill(uint(config.navigationCustomize.@blockColor), Number(config.navigationCustomize.@blockAlpha));
			this.graphics.drawRect(0, 0, 10, 10);
			this.graphics.endFill();
			
			//Listeners
			this.stage.addEventListener(Event.RESIZE, onResize);
			
			//Actions
			onResize(null);
			TweenLite.from(this, 0.5, {alpha:0});
		}
		
		private function destroy() : void {
			this.stage.removeEventListener(Event.RESIZE, onResize);
			this.stage.removeChild(this);
		}

		public function remove() : void {
			TweenLite.to(this, 0.5, {autoAlpha:0, onComplete: destroy});
		}

		/**
		 * Events
		 */
		private function onResize(e : Event) : void {
			this.width = stage.stageWidth;
			this.height = stage.stageHeight;
		}
	}
}
